package pl.mchaniewski.ryneczek.pojo;

// Generated Oct 3, 2011 3:17:38 AM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "portfolio", catalog = "stockmarket")
public class Portfolio implements java.io.Serializable {
    private static final long serialVersionUID = -733096890992206411L;

    private Integer portfolioid;
    private User user;
    private String name;
    private BigDecimal originalBalance;
    private BigDecimal balance;
    private Date createDate;
    private BigDecimal totalCommissions;
    private Set<Order> orders = new HashSet<Order>(0);

    public static final Integer MAXIMUM_PORTFOLIOS = 5;

    public Portfolio() {
    }

    public Portfolio(User user, String name, BigDecimal originalBalance,
            BigDecimal balance, Date createDate, BigDecimal totalCommissions) {
        this.user = user;
        this.name = name;
        this.originalBalance = originalBalance;
        this.balance = balance;
        this.createDate = createDate;
        this.totalCommissions = totalCommissions;
    }

    public Portfolio(User user, String name, BigDecimal originalBalance,
            BigDecimal balance, Date createDate, BigDecimal totalCommissions,
            Set<Order> orders) {
        this.user = user;
        this.name = name;
        this.originalBalance = originalBalance;
        this.balance = balance;
        this.createDate = createDate;
        this.totalCommissions = totalCommissions;
        this.orders = orders;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "PORTFOLIOID", unique = true, nullable = false)
    public Integer getPortfolioid() {
        return portfolioid;
    }

    public void setPortfolioid(Integer portfolioid) {
        this.portfolioid = portfolioid;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "USERID", nullable = false)
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Column(name = "NAME", nullable = false, length = 20)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "ORIGINAL_BALANCE", nullable = false)
    public BigDecimal getOriginalBalance() {
        return originalBalance;
    }

    public void setOriginalBalance(BigDecimal originalBalance) {
        this.originalBalance = originalBalance;
    }

    @Column(name = "BALANCE", nullable = false)
    public BigDecimal getBalance() {
        return balance;
    }

    public void setBalance(BigDecimal balance) {
        this.balance = balance;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "CREATE_DATE", nullable = false, length = 19)
    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Column(name = "TOTAL_COMMISSIONS", nullable = false)
    public BigDecimal getTotalCommissions() {
        return totalCommissions;
    }

    public void setTotalCommissions(BigDecimal totalCommissions) {
        this.totalCommissions = totalCommissions;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "portfolio")
    public Set<Order> getOrders() {
        return orders;
    }

    public void setOrders(Set<Order> orders) {
        this.orders = orders;
    }

}
